package com.mcxx.modules.fund.controller;

import com.mcxx.modules.fund.service.FundPayNoTranslationService;
import com.mcxx.modules.fund.service.FundPayService;
import com.mcxx.result.BaseResult;
import com.mcxx.service.DefaultRestService;
import com.mcxx.util.Constant;
import com.yinhai.ta404.core.restservice.annotation.RestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;


@Slf4j
@Validated
@Api(tags="名册生成控制类")
@RestService({"fundpay/v2"})
public class FundController extends DefaultRestService {
    @Autowired
    private FundPayService fundPayService;
    @Autowired
    private FundPayNoTranslationService fundPayNoTranslationService;

    @PostMapping("addTempFundPay")
    @ApiOperation("创建临时救助资金发放名册")
    @ApiImplicitParams({
        @ApiImplicitParam(name="areaCode", value="地区：12位地区码", required = true, paramType="query",   dataType="string"),
        @ApiImplicitParam(name="payDate", value="发放年月：2021年6月-202106", required = true, paramType="query",dataType="string"),
        @ApiImplicitParam(name="payWay", value="发放方式：01银行卡02现金03实物", required = true, paramType="query",dataType="string")
    })
    public void addTempFundPay(String areaCode, String payDate, String payWay) {
        log.info("创建临时救助资金发放名册,参数：{}, {}, {}", areaCode, payDate, payWay);

        BaseResult<Boolean> result = fundPayService.addTempFundPay(areaCode, payDate, payWay, Constant.IsAuto.YES);
        setData(result);
        log.info("创建临时救助资金发放名册,结果：{}", true);
    }


    @PostMapping("addCapitalFundPay")
    @ApiOperation("创建低保保障金发放名册")
    @ApiImplicitParams({
            @ApiImplicitParam(name="areaCode", value="地区:12位地区码", required = true, paramType="query",dataType= "String"),
            @ApiImplicitParam(name="payDate", value="发放年月:2021年6月-202106", required = true, paramType="query",dataType= "String"),
            @ApiImplicitParam(name="standType", value="标准:01城市02农村", required = true, paramType="query",dataType= "String")
    })
    public void addCapitalFundPay(String areaCode, String payDate, String standType) {
        log.info("创建低保保障金发放名册,参数：{}, {}, {}", areaCode, payDate, standType);

        BaseResult<Boolean> result = fundPayService.addCapitalFundPay(areaCode, payDate, standType, Constant.IsAuto.YES);
        setData(result);
        log.info("创建低保保障金发放名册,结果：{}", true);
    }


    @PostMapping("addExCapitalFundPay")
    @ApiOperation("创建特困资金发放名册")
    @ApiImplicitParams({
            @ApiImplicitParam(name="areaCode", value="地区:12位地区码", required = true, paramType="query",dataType= "String"),
            @ApiImplicitParam(name="payDate", value="发放年月:2021年6月-202106", required = true, paramType="query",dataType= "String"),
            @ApiImplicitParam(name="standType", value="标准:03城市04农村", required = true, paramType="query",dataType= "String"),
            @ApiImplicitParam(name="supplyType", value="供养方式:01集中供养02分散供养", required = true, paramType="query",dataType= "String"),
            @ApiImplicitParam(name="costType", value="费用类型:310基本生活费330照料费", required = true, paramType="query",dataType= "String")
    })
    public void addExCapitalFundPay(String areaCode, String payDate, String standType, String supplyType, String costType) {
        log.info("创建特困资金发放名册,参数：{}, {}, {}, {}, {}", areaCode, payDate, standType, supplyType, costType);

        BaseResult<Boolean> result = fundPayService.addExCapitalFundPay(areaCode, payDate, standType, supplyType,
                                                costType, Constant.IsAuto.YES);
        setData(result);
        log.info("创建特困资金发放名册,结果：{}", true);
    }


    @PostMapping("addFuneralFundPay")
    @ApiOperation("创建丧葬费发放名册")
    @ApiImplicitParams({
            @ApiImplicitParam(name="areaCode", value="地区:12位地区码", required = true, paramType="query",dataType= "String"),
            @ApiImplicitParam(name="payDate", value="发放年月:2021年6月-202106", required = true, paramType="query",dataType= "String"),
            @ApiImplicitParam(name="standType", value="标准:03城市04农村", required = true, paramType="query",dataType= "String"),
            @ApiImplicitParam(name="takeType", value="领取人类型:0个人 1机构", required = true, paramType="query",dataType= "String")
    })
    public void addFuneralFundPay(String areaCode, String payDate, String standType, String takeType) {
        log.info("创建丧葬费发放名册,参数：{}, {}, {}", areaCode, payDate, standType);

        BaseResult<Boolean> result = fundPayService.addFuneralFundPay(areaCode, payDate, standType, takeType, Constant.IsAuto.YES);
        setData(result);
        log.info("创建丧葬费发放名册,结果：{}", true);
    }


    @PostMapping("addProvinceFuneralFundPay")
    @ApiOperation("创建全省丧葬费发放名册")
    @ApiImplicitParams({
            @ApiImplicitParam(name="payDate", value="发放年月:202106", required = true, paramType="query",dataType= "String"),
    })
    public void addProvinceFuneralFundPay(String payDate) {
        log.info("创建全省丧葬费发放名册,参数：{}",  payDate);
        BaseResult<Boolean> result = fundPayNoTranslationService.addProvinceFuneralFundPay(payDate, Constant.IsAuto.YES);
        setData(result);
        log.info("创建全省丧葬费发放名册,结果：{}", true);
    }


    @PostMapping("createFundPay")
    @ApiOperation("按月补全资金发放名册")
    @ApiImplicitParams({
            @ApiImplicitParam(name="areaCode", value="地区码", required = false, paramType="query",dataType= "String"),
            @ApiImplicitParam(name="payDate", value="发放年月:2021年6月-202106,多个逗号分隔", required = true, paramType="query",dataType= "String"),
            @ApiImplicitParam(name="businessType", value="业务类型:110低保130特困500临时救助", required = false, paramType="query",dataType= "String")
    })
    public void createFundPay(String areaCode, String payDate, String businessType) {
        log.info("创建特困资金发放名册,参数：{}, {}", payDate, businessType);

        BaseResult<Boolean> result = fundPayNoTranslationService.createFundPay(areaCode, payDate, businessType);
        setData(result);
        log.info("创建特困资金发放名册,结果：{}", true);
    }
}
